<template>
  <div id="contain">
    <el-table
      :data="tableList"
      style="width: 945px"
      stripe
      :row-style="rowStyle"
      :cell-style="cellStyle"
      height="720"
    >
      <el-table-column prop="name" label="线路名" width="180" align="center">
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" align="center">
      </el-table-column>
      <el-table-column prop="adNum" label="成人数量" align="center">
      </el-table-column>
      <el-table-column prop="chNum" label="孩童数量" align="center">
      </el-table-column>
      <el-table-column prop="pay" label="总价" align="center">
      </el-table-column>
      <el-table-column prop="status" label="完成状态" align="center">
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="mini" @click="chakan(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="page"
      :page-sizes="[5, 10, 20]"
      :page-size="limit"
      layout="sizes, prev, pager, next"
      :total="totalCount"
    >
    </el-pagination>
    <el-dialog :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="服务名称" :label-width="formLabelWidth">
          <el-input v-model="form.name" disabled></el-input>
        </el-form-item>
        <el-form-item label="服务线路" :label-width="formLabelWidth">
          <el-input v-model="form.route" disabled></el-input>
        </el-form-item>
        <el-form-item label="服务起点" :label-width="formLabelWidth">
          <el-input v-model="form.startAddr" disabled></el-input>
        </el-form-item>
        <el-form-item label="服务终点" :label-width="formLabelWidth">
          <el-input v-model="form.endAddr" disabled></el-input>
        </el-form-item>
        <el-form-item label="儿童数量" :label-width="formLabelWidth">
          <el-input v-model="form.chNum" disabled></el-input>
        </el-form-item>
        <el-form-item label="成人数量" :label-width="formLabelWidth">
          <el-input v-model="form.adNum" disabled></el-input>
        </el-form-item>
        <el-form-item label="总价" :label-width="formLabelWidth">
          <el-input v-model="form.pay" disabled></el-input>
        </el-form-item>
        <el-form-item label="订单完成状态" :label-width="formLabelWidth">
          <el-input v-model="form.status" disabled></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="dialogFormVisible = false"
            style="float: right"
            >确 定</el-button
          >
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      token: window.localStorage.getItem("token"),
      tableList: [],
      form: {},
      formLabelWidth: "120px",
      dialogFormVisible: false,
      page: 1,
      limit: 10,
      totalCount: 10,
    };
  },
  mounted() {
    this.fn();
  },
  methods: {
    fn() {
      this.$axios({
        method: "post",
        url: "/order/list/merchant/uncompleted",
        headers: { token: this.token },
        data: { page: this.page, limit: this.limit, type: 1 },
      }).then((res) => {
        // console.log("未完成订单");
        // console.log(res);
        if (res.data.code === 0) {
          this.tableList = res.data.page.regard;
          this.totalCount = res.data.page.totalCount;
           this.tableList.forEach((item) => {
            item.status =
              item.status === 1
                ? "已支付"
                : item.status === 0
                ? "未支付"
                : "待评价";
          });
        }
        if (res.data.code === 500) {
          this.$message({
            type: "error",
            message: res.data.msg,
          });
        }
      });
    },
    rowStyle() {
      return { height: "60px" };
    },
    cellStyle(k) {
      if (k.columnIndex === 5) {
        if (k.row.status === "已支付") {
          return { color: "#33CC00" };
        } else if (k.row.status === "待评价") {
          return { color: "blue" };
        } else {
          return { color: "red" };
        }
      }
    },
    chakan(k) {
    //   console.log(k);
    this.dialogFormVisible=true
      this.form=k
    },
    handleSizeChange(val) {
      this.limit = val;
      this.fn();
    },
    handleCurrentChange(val) {
      this.page = val;
      this.fn();
    },
  },
};
</script>
<style  scoped>
</style>>